<?php
/* @var $this NewsController */
/* @var $model News */
/* @var $form CActiveForm */
?>
<script>
   $(function(){
        var str = $("#News_newstype_id option:selected").text();
        if (str == "图片内容新闻" || str == "小屏滚动新闻"|| str == "顶部滚动新闻") 
        {
            $("#urlnews").show();
        }
        else
        {
            $("#urlnews").hide();
        }

        $("#News_newstype_id").on("change", function(){
        var str = $("#News_newstype_id option:selected").text();
        if (str == "图片内容新闻" || str == "小屏滚动新闻"|| str == "顶部滚动新闻") 
        {
            $("#urlnews").show();
        }
        else
        {
            $("#urlnews").hide();
        }
    });
});
</script>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'news-form',
    'enableAjaxValidation'=>false,
    'clientOptions'=>array( 'validateOnSubmit'=>true,),
    'htmlOptions'=>array('enctype'=>'multipart/form-data'),
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

<!--	<div class="row">
		<?php //echo $form->labelEx($model,'user_id'); ?>
		<?php //echo $form->textField($model,'user_id'); ?>
		<?php //echo $form->error($model,'user_id'); ?>
	</div> --!>

	<div class="row">
		<?php echo $form->labelEx($model,'newstype_id'); ?>
		<?php //echo $form->textField($model,'newstype_id'); ?>
		<?php echo $form->dropDownList($model,'newstype_id', $model->getNewsTypeOptions());?>
		<?php echo $form->error($model,'newstype_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'priority'); ?>
		<?php echo $form->textField($model,'priority'); ?>
		<?php echo $form->error($model,'priority'); ?>
	</div>

<!--	<div class="row">
		<?php //echo $form->labelEx($model,'views'); ?>
		<?php //echo $form->textField($model,'views'); ?>
		<?php //echo $form->error($model,'views'); ?>
	</div>-->

<!--	<div class="row">
		<?php //echo $form->labelEx($model,'published_date'); ?>
		<?php //echo $form->textField($model,'published_date'); ?>
		<?php //echo $form->error($model,'published_date'); ?>
	</div>-->

	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model,'title',array('size'=>60,'maxlength'=>200)); ?>
		<?php echo $form->error($model,'title'); ?>
    </div>
    <?php if($model->isNewRecord == false && ($model->news_id == 2 || $model->news_id == 3 || $model->news_id == 6)):?>
    <div id="urlnews">
    <?php else:?>
    <div id="urlnews" style="display:none">
    <?php endif;?>
    <div class="row">
        <?php echo $form->labelEx($model,'url'); ?>
        <?php echo $form->textField($model,'url',array('size'=>60,'maxlength'=>200));?>
        <?php echo $form->error($model,'url'); ?>
    </div>

    <div class="form-group">
        <img src="<?php echo yii::app()->baseUrl.'/'.$model->url;?>" id="imageViewer" width=100% height=350></img>
        <input type="file" id="newsImageView" name="imageFile" style="width:100%;" accept="image/*" onchange="return newsImagePreview()"/>
    </div>
    </div>
	<div class="row">
		<?php echo $form->labelEx($model,'content'); ?>
		<?php echo $form->textArea($model,'content',array('rows'=>6, 'cols'=>50)); ?>
  		<script type="text/javascript">
			var editor = new UE.ui.Editor();
			editor.render("News_content");
		</script>
        <?php echo $form->error($model,'content'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'status'); ?>
		<?php //echo $form->textField($model,'status'); ?>
		<?php echo $form->dropDownList($model,'status', $model->getStatusOptions());?>
		<?php echo $form->error($model,'status'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
